package com.booksys.controller;

import com.booksys.pojo.Visited;
import com.booksys.result.ResultUtil;
import com.booksys.service.VisitedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 图书管理Controller
 */
@RestController
@RequestMapping("/visited")
@CrossOrigin
@Api(tags = "旅游地接口")
public class VisitedController {
    @Autowired
    private VisitedService visitedService;

    /**
     * 查询旅游过的信息
     * @param userId
     * @param provinceId
     * @return
     */
    @ApiOperation(value = "通过用户ID和省份ID获取旅游过的城市")
    @RequestMapping(value = "/queryVisited", method={RequestMethod.POST, RequestMethod.GET})
    public ResultUtil<List<Visited>> queryVisited(int userId, int provinceId){
        ResultUtil<List<Visited>> listResultUtil = new ResultUtil<>();

        List<Visited> list = visitedService.queryVisited(userId, provinceId);
        return listResultUtil.success();
    }

    /**
     * 查询旅游过的信息
     * @param visited
     * @return
     */
    @ApiOperation(value = "添加旅游记录")
    @RequestMapping(value = "/insertVisited", method={RequestMethod.POST, RequestMethod.GET})
    public ResultUtil<Visited> insertVisited(Visited visited){
        ResultUtil<Visited> resultUtil = new ResultUtil<>();
        visitedService.insertVisited(visited);
        return resultUtil.success(visited);
    }

}
